package com.pb.wkflow.api.controller;

import com.pb.infra.oth.entity.common.Result;
import com.pb.wkflow.api.service.ParticipantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 苗益辉
 * @date 2022/9/22 9:32
 */
@RestController
@RequestMapping("v1/workflow/participant")
public class ParticipantApi {

    @Autowired
    ParticipantService participantService;

    /**
     * 查询用户参与者
     * @param pageIndex 页码
     * @param pageSize 页数
     * @param keyword 查询条件
     * @return Result
     */
    @GetMapping("getUserList")
    public Result getUserList(@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
                              @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
                              @RequestParam(value = "keyword", required = false) String keyword) {
        return participantService.getUserList(pageIndex, pageSize, keyword);
    }

    /**
     * 查询组织参与者
     * @return Result
     */
    @GetMapping("getStructList")
    public Result getStructList() {
        return participantService.getStructList();
    }

    /**
     * 查询岗位参与者
     * @param postName 岗位名称
     * @param pageSize 页数
     * @param pageIndex 页码
     * @return Result
     */
    @GetMapping("getPostList")
    public Result getPostList(@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
                              @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
                              @RequestParam(value = "postName", required = false) String postName) {
        return participantService.getPostList(pageIndex, pageSize,postName);
    }

    /**
     * 查询角色参与者
     * @param roleName 角色名称
     * @param pageSize 页数
     * @param pageIndex 页码
     * @return Result
     */
    @GetMapping("getRoleList")
    public Result getRoleList(@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
                              @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
                              @RequestParam(value = "roleName", required = false) String roleName) {
        return participantService.getRoleList(pageIndex, pageSize, roleName);
    }
}
